package com.hut.oa.model.bean;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 笔记管理
 * @author zdd
 *
 */
@Entity
@Table(name="notes_")
public class Notes {
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="not_id")
	private Long id;//笔记id
	
	@JoinColumn(name="not_dir_id")
	@ManyToOne(fetch=FetchType.EAGER)
	@JsonIgnore
	private NoteDir dir;//类型id
	
	@Column(name="not_title",nullable=false)
	private String title;//标题
	
	@Column(name="not_permission",nullable=false)
	private String permission="0";//权限
	
	@Column(name="not_update_time",nullable=false)
	private Date updateTime;//更新时间
	
	@Column(name="not_content",nullable=false)
	private String content;//内容
	
	@JoinColumn(name="not_user_id",nullable=false)
	@ManyToOne
	@JsonIgnore
	private User userId;//用户id
	
	@Column(name="not_is_delete",nullable=false)
	private Integer isDelete=0;//是否加入回收站

	@Column(name="not_is_star",nullable=false)
	private Integer isstar=0;//收藏
	
	@JsonIgnore
	@ManyToMany(cascade=CascadeType.ALL,fetch = FetchType.LAZY)
	@JoinTable(name = "note_user",
    joinColumns = {
            @JoinColumn(name = "nu_note_id")
    }, inverseJoinColumns = {
    @JoinColumn(name = "nu_user_id")
})
	private List<User> noteuser;
	
	public Notes() {}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public NoteDir getDir() {
		return dir;
	}

	public void setDir(NoteDir dir) {
		this.dir = dir;
	}

	public Integer getIsstar() {
		return isstar;
	}

	public void setIsstar(Integer isstar) {
		this.isstar = isstar;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getPermission() {
		return permission;
	}

	public void setPermission(String permission) {
		this.permission = permission;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}
	
	public User getUserId() {
		return userId;
	}

	public void setUserId(User userId) {
		this.userId = userId;
	}

	public Integer getIsDelete() {
		return isDelete;
	}

	public void setIsDelete(Integer isDelete) {
		this.isDelete = isDelete;
	}

	public List<User> getNoteuser() {
		return noteuser;
	}

	public void setNoteuser(List<User> noteuser) {
		this.noteuser = noteuser;
	}

	@Override
	public String toString() {
		return "Notes [id=" + id + ", title=" + title + ", permission="
				+ permission + ", updateTime=" + updateTime + ", content=" + content + ", userId=" + userId
				+ ", isDelete=" + isDelete + "]";
	}
	
}




